package com.artPreter.controller;


import com.artPreter.pojo.OnlineType;
import com.artPreter.pojo.Result;
import com.artPreter.service.IOnlineTypeService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 作品在线分类表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-12-16
 */
@RestController
@RequestMapping("/onlineType")
public class OnlineTypeController {
    
    @Autowired
    private IOnlineTypeService onlineTypeService;

    /**
     * 作品在线分类分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody OnlineType onlineType) {
        IPage<OnlineType> onlineTypeIPage = onlineTypeService.getPage(currentPage, size, onlineType);
        return Result.success(onlineTypeIPage);
    }

    /**
     *  添加作品在线分类
     * @param onlineType
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody OnlineType onlineType) {
        onlineTypeService.add(onlineType);
        return Result.success();
    }

    /**
     *  修改作品在线分类
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody OnlineType onlineType) {
        onlineTypeService.edit(onlineType);
        return Result.success();
    }

    /**
     * 删除作品在线分类
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody OnlineType onlineType){
        onlineTypeService.delete(onlineType);
        return Result.success();
    }

    /**
     * 获取作品在线分类列表
     * @param
     * @return
     */
    @PostMapping("/getList")
    public Result getList(@RequestBody OnlineType onlineType){
        List<OnlineType> result = onlineTypeService.getList(onlineType);
        return Result.success(result);
    }

}
